import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ShopCashierVO, ShopCashierForm, ShopCashierQuery } from '@/api/retail/shopCashier/types';

/**
 * 查询商店收银员列表
 * @param query
 * @returns {*}
 */

export const listShopCashier = (query?: ShopCashierQuery): AxiosPromise<ShopCashierVO[]> => {
  return request({
    url: '/shop/cashier/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商店收银员详细
 * @param id
 */
export const getShopCashier = (id: string | number): AxiosPromise<ShopCashierVO> => {
  return request({
    url: '/shop/cashier/' + id,
    method: 'get'
  });
};

/**
 * 新增商店收银员
 * @param data
 */
export const addShopCashier = (data: ShopCashierForm) => {
  return request({
    url: '/shop/cashier',
    method: 'post',
    data: data
  });
};

/**
 * 修改商店收银员
 * @param data
 */
export const updateShopCashier = (data: ShopCashierForm) => {
  return request({
    url: '/shop/cashier',
    method: 'put',
    data: data
  });
};

/**
 * 修改状态
 * @param id
 * @param status
 */
export const changeCashierStatus = (id: string | number, status: string | number) => {
  const data = {
    id,
    status
  };
  return request({
    url: '/shop/cashier/changeStatus',
    method: 'post',
    data: data
  });
}
/**
 * 删除商店收银员
 * @param id
 */
export const delShopCashier = (id: string | number | Array<string | number>) => {
  return request({
    url: '/shop/cashier/' + id,
    method: 'delete'
  });
};
